const app = getApp()
Page({
  data: {
    array: ['中国', '新加坡', '日本', '香港', '韩国', '台湾', '澳门'],
    arrayNum: ['86', '65', '81', '852', '82', '886', '853'],
    index: 0,
    mobile: "",
    truecode:"12121",
    vcode:"",
    tname:'',
    classname:'',
    mopenId: 'wqwqwqw'
  },

  onLoad () {
    this.setData({
      mopenId: app.globalData.mopenid
    })
  },

  onPullDownRefresh () {
    wx.stopPullDownRefresh()
  },

  bindPickerChange (e) {
    this.setData({
      index: e.detail.value
    })
  },

  bindMobileInput (e) {
    console.log(e.detail.value)
    this.setData({
      mobile: e.detail.value
    })
  },
  bindClassInput(e){
    this.setData({
      classname: e.detail.value
    })
  },
  bindvcodeInput(e){
    console.log(e.detail.value)
    this.setData({
      vcode: e.detail.value
    })
  },
  bindTnameInput(e){
    this.setData({
      tname: e.detail.value
    })
  }
,
  bindGetVerification () {
    let that = this
   
    wx.request({
      url: 'https://migou.justmetu.top/api/shop/login/get_phone_code',
      data:{
        mobile:that.data.mobile,
      },
      success:function(res){
          that.setData({
            truecode:res.data.data,
          })
      }
    })
  },

  formSubmit: function(e) {
    var that=this
    var app=getApp()
    if(this.data.truecode==this.data.vcode){
      wx.request({
        url: 'https://thtl.vip/jishu/doRegister',
        data: {
          tel: that.data.mobile,
          name: that.data.tname,
          classname:that.data.classname,
          openId: that.data.mopenId
        },
        success: function (res) {
          console.log(res.data)
          if(res.data.id!=""){
            app.globalData.goRe = false;
            
            wx.navigateTo({
              url: "../../../pages/index/index"
            })
          }
          that.setData({
            truecode: res.data
          })
        }
      })
    }else{

    }
 
  }
})
